<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="Content-Script-Type" content="text/javascript" />
		<meta http-equiv="Content-Style-Type" content="text/css" />
		<title>コントロールパネル</title>
		<link rel="stylesheet" href="./assets/styles/default.css" type="text/css" />
		<link rel="stylesheet" href="./assets/styles/ui-lightness/ui.all.css" type="text/css" />
		
		<link rel="stylesheet" href="./assets/styles/ui-lightness/jquery-ui-1.7.3.custom.css" type="text/css" />
		<link rel="stylesheet" href="./assets/styles/dialog.css" type="text/css" />
		
		<script src="assets/scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
		<script src="assets/scripts/jquery-ui-1.7.3.custom.min.js" type="text/javascript"></script>
		<script src="assets/scripts/ui/ui.dialog.js" type="text/javascript"></script>
		
		
		<script src="assets/scripts/menu.js" type="text/javascript"></script>
		<script src="assets/scripts/table.js" type="text/javascript"></script>
		<script type="text/javascript" src="./assets/scripts/tiny_mce/tiny_mce.js"></script>
		
		<script type="text/javascript" src="./assets/scripts/editor.js"></script>
		<script type="text/javascript" src="./assets/scripts/ui/ui.datepicker.js"></script>
		<script type="text/javascript" src="./assets/scripts/ui/ui.core.js"></script>
		<script type="text/javascript" src="./assets/scripts/search.js"></script>
		<script type="text/javascript">
		$(function() {
			$('.message').fadeIn("slow");
			$('.btn_regist').click(function(){
				if( confirm('登録してよろしいですか？') ){
					document.fm.mode.value = 'input';
					document.fm.submit();
				}
			});
			$('button.tddel').live('click',function(){
				$(this).closest('tr').remove();
				
			});
		
			$('.btn_update').click(function(){
				if( confirm('更新してよろしいですか？') ){
					document.fm.mode.value = 'input';
					document.fm.submit();
				}
			});
			$('.btn_return').click(function(){
				location.href = "mcost_dm_index.php?hist=2";
			});
			
			$('.text_date').datepicker({
				changeMonth: true,
				changeYear: true,
				dateFormat: 'yy/mm/dd'
			});
		});
		
		function setS(  valnm ) {
			//eval("document.fm." +  gPara + "_cd.value = " + valcd);
			eval("document.fm." +  gPara + "_name.value ='" + valnm + "'");			
			$('#dialog').dialog("close");
		}
		
		function li_add(objID,inID, inVal) {
			if (checkNames(inID)) {
				var strHtml = "<li id='a" + inID +"' class='item_li'> <a href='#'  style='color:red' class='li_del' >X</a>&nbsp;&nbsp;"+ inID + "&nbsp;&nbsp;" + inVal;
				if (typeof(g_shop_ul_to_grid)!="undefined") {
					strHtml = strHtml + "<input type='hidden' value='" + inID  + "' name ='"  + gMutiObj + "_cd_ul[]'>";
					strHtml = strHtml + "<input type='hidden' value='" + inVal + "' name ='" + gMutiObj + "_name_ul[]'>";
				} else {
					strHtml = strHtml + "<input type='hidden' value='" + inID  + "' name ='"  + gMutiObj + "_cd[]'>";
					strHtml = strHtml + "<input type='hidden' value='" + inVal + "' name ='" + gMutiObj + "_name[]'>";
				}
				strHtml = strHtml + "</li>";
				$("#" + objID +"_ul").append(strHtml);
			}
		}
		var g_shop_ul_to_grid = true ;
		function add_tr(vid, vname) {
			var table = $('#table_shop');
			var str = '<tr><td> ' + vid + '</td><td>' + vname + ' </td><td> <input type="text" id="p_'+ vid +'" name=count[]" class="text nper" value = ""/> ';
			str = str + "<input type='hidden' value='" + vid  + "' name ='"  + gMutiObj + "_cd[]'>";
			str = str + "<input type='hidden' value='" + vname + "' name ='" + gMutiObj + "_name[]'>";
			//str = str + '<td> <input type="text"  id="n_'+ vid +'"  name='   + gMutiObj + '_nums[]" class="text nnum"  readonly="readonly" value = ""/></td> '
			str = str + '<td align="center"><button type="button" class="tddel">削除</button> </td></tr>';
			
			$(table).append(str);
		}
		
		function copy_shop_pop_ul_to_grid() {
			var cdsul   = document.getElementsByName(gMutiObj + '_cd_ul[]');
			var namesul = document.getElementsByName(gMutiObj + '_name_ul[]');
			var cdarr   = new Array();
			$.each(cdsul, function(i,val){
				cdarr[i] = val.value;
			}); 
			//var html = $("#table_shop tr:last").html();
           // html = "<tr>" + html + "</tr>";
          //  $("#table_shop tr:last").remove();
			$.each(namesul, function(i,val){
				add_tr(cdarr[i], val.value)
			}); 
			//$("#table_shop").append(html);
		}
		</script>
		
	</head>
	<body id="">
{{ $menu }}
{{ $logout }}
		<div id="container"><div class="wrapper">
			<h2>DM経費マスター管理</h2>
			<ul class="submenu clearfix">
				<li>一覧.更新</li>
				<li><a href="mcost_dm_d_import.php">明細表登録</a></li>
				<li><a href="mcost_dm_c_import.php">件数表登録</a></li>
				<li><a href="mcost_dm_price.php">DM単価マスタ</a></li>
				{{	if ($now_menu.mcost_dm_plane_index.auth) }}<li><a href="mcost_dm_plane_index.php">経費一覧.更新</a></li>{{ /if }}
				{{	if ($now_menu.mcost_dm_plane_import.auth) }}<li><a href="mcost_dm_plane_import.php">経費一括登録</a></li>{{ /if }}
			</ul>
			<h3>DM経費一覧.更新　</h3>
{{ if $phase == 'input' }}
			<p class="message">内容を確認し、{{ if $forms.id == '' }}登録{{ else }}更新{{ /if }}ボタンをクリックしてください。</p>
			<form name="fm" action="mcost_dm_form.php" method="post">
				<table class="formTable">
					<tbody>
{{ if $forms.id != '' }}
						<tr>
							<th>更新日</th>
							<td>
								{{ $forms.u_time|date_format:"%Y/%m/%d %H:%M" }}<input type="hidden" name="u_time" value="{{ $forms.u_time }}" />
							</td>
						</tr>
						<tr>
							<th>更新者</th>
							<td>
								{{ $forms.m_user_name }}<input type="hidden" name="m_user_name" value="{{ $forms.m_user_name }}" />
							</td>
						</tr>
						<tr>
							<th>ID</th>
							<td>
								{{ $forms.id }}
							</td>
						</tr>
						<tr>
							<th>差替ＮＯ</th>
							<td>
	<input type="text" name="dm_no"  value="{{ $forms.dm_no|escape }}"   class="dtext" readonly  />{{ $err.dm_no }}
	<input type="hidden" name="matrix_cd" value="{{ $forms.matrix_cd }}" />

							</td>
						</tr>
{{ /if }}
						<tr>
							<th><span>※</span>セール期間</th>
							<td>
	<input type="text" name="begin_date"  value="{{ $forms.begin_date|escape }}"  {{ if $eflg == '1' }} class="text_date" {{ else }} class="dtext" readonly {{ /if }} />{{ $err.begin_date }}
	 ～ 
	<input type="text" name="end_date"  value="{{ $forms.end_date|escape }}"  {{ if $eflg == '1' }} class="text_date" {{ else }} class="dtext" readonly {{ /if }} />{{ $err.end_date }}
							</td>
						</tr><tr>
							<th><span>※</span>投函日</th>
							<td>
	<input type="text" name="dm_date"  value="{{ $forms.dm_date|escape }}"  {{ if $eflg == '1' }} class="text_date" {{ else }} class="dtext" readonly {{ /if }} />{{ $err.dm_date }}
							</td>
						</tr><!--  <tr>
							<th><span>※</span>DMコード</th>
							<td>
	<input type="text" name="dm_cd"  value="{{ $forms.dm_cd|escape }}"  {{ if $eflg == '1' }} class="text" {{ else }} class="dtext" readonly {{ /if }} />{{ $err.dm_cd }}
							</td>
						</tr>--><tr>
							<th><span>※</span>タイトル</th>
							<td>
	<input type="text" name="title"  value="{{ $forms.title|escape }}"  {{ if $eflg == '1' }} class="text" {{ else }} class="dtext" readonly {{ /if }} />{{ $err.title }}

							</td>
						</tr><tr>

							<th><span>※</span>種類</th>
							<td>
	<input type="text" name="sort"  value="{{ $forms.sort|escape }}"  {{ if $eflg == '1' }} class="text" {{ else }} class="dtext" readonly {{ /if }} />{{ $err.sort }}

							</td>
						</tr><tr>

							<th>ハガキ表</th>
							<td>
	<input type="text" name="haga_out"  value="{{ $forms.haga_out|escape }}"  {{ if $eflg == '1' }} class="text" {{ else }} class="dtext" readonly {{ /if }} />{{ $err.haga_out }}

							</td>
						</tr><tr>
							<th>ハガキ裏</th>
							<td>
	<input type="text" name="haga_in"  value="{{ $forms.haga_in|escape }}"  {{ if $eflg == '1' }} class="text" {{ else }} class="dtext" readonly {{ /if }} />{{ $err.haga_in }}

							</td>
						</tr><tr>
							<th>封筒</th>
							<td>
	<input type="text" name="futou"  value="{{ $forms.futou|escape }}"  {{ if $eflg == '1' }} class="text" {{ else }} class="dtext" readonly {{ /if }} />{{ $err.futou }}

							</td>
						</tr><tr>
							<th>プレ券表</th>
							<td>
	<input type="text" name="preken_out"  value="{{ $forms.preken_out|escape }}"  {{ if $eflg == '1' }} class="text" {{ else }} class="dtext" readonly {{ /if }} />{{ $err.preken_out }}

							</td>
						</tr><tr>
							<th>プレ券裏</th>
							<td>
	<input type="text" name="preken_in"  value="{{ $forms.preken_in|escape }}"  {{ if $eflg == '1' }} class="text" {{ else }} class="dtext" readonly {{ /if }} />{{ $err.preken_in }}

							</td>
						</tr><tr>
							<th>割引券表</th>
							<td>
	<input type="text" name="wariken_out"  value="{{ $forms.wariken_out|escape }}"  {{ if $eflg == '1' }} class="text" {{ else }} class="dtext" readonly {{ /if }} />{{ $err.wariken_out }}

							</td>
						</tr><tr>
							<th>割引券裏</th>
							<td>
	<input type="text" name="wariken_in"  value="{{ $forms.wariken_in|escape }}"  {{ if $eflg == '1' }} class="text" {{ else }} class="dtext" readonly {{ /if }} />{{ $err.wariken_in }}

							</td>
						</tr><tr>
							<th>宛名表</th>
							<td>
	<input type="text" name="atemei_out"  value="{{ $forms.atemei_out|escape }}"  {{ if $eflg == '1' }} class="text" {{ else }} class="dtext" readonly {{ /if }} />{{ $err.atemei_out }}

							</td>
						</tr><tr>
							<th>宛名裏</th>
							<td>
	<input type="text" name="atemei_in"  value="{{ $forms.atemei_in|escape }}"  {{ if $eflg == '1' }} class="text" {{ else }} class="dtext" readonly {{ /if }} />{{ $err.atemei_in}}

							</td>
						</tr><tr>
							<th>ペラ１表</th>
							<td>
	<input type="text" name="pera1_out"  value="{{ $forms.pera1_out|escape }}"  {{ if $eflg == '1' }} class="text" {{ else }} class="dtext" readonly {{ /if }} />{{ $err.pera1_out }}

							</td>
						</tr><tr>
							<th>ペラ１裏</th>
							<td>
	<input type="text" name="pera1_in"  value="{{ $forms.pera1_in|escape }}"  {{ if $eflg == '1' }} class="text" {{ else }} class="dtext" readonly {{ /if }} />{{ $err.pera1_in }}

							</td>
						</tr><tr>
							<th>ペラ2表</th>
							<td>
	<input type="text" name="pera2_out"  value="{{ $forms.pera2_out|escape }}"  {{ if $eflg == '1' }} class="text" {{ else }} class="dtext" readonly {{ /if }} />{{ $err.pera2_out }}

							</td>
						</tr><tr>
							<th>ペラ2裏</th>
							<td>
	<input type="text" name="pera2_in"  value="{{ $forms.pera2_in|escape }}"  {{ if $eflg == '1' }} class="text" {{ else }} class="dtext" readonly {{ /if }} />{{ $err.pera2_in }}

							</td>
						</tr><tr>
							<th>挨拶状表</th>
							<td>
	<input type="text" name="ayisatu_out"  value="{{ $forms.ayisatu_out|escape }}"  {{ if $eflg == '1' }} class="text" {{ else }} class="dtext" readonly {{ /if }} />{{ $err.ayisatu_out }}

							</td>
						</tr><tr>
							<th>挨拶状裏</th>
							<td>
	<input type="text" name="ayisatu_in"  value="{{ $forms.ayisatu_in|escape }}"  {{ if $eflg == '1' }} class="text" {{ else }} class="dtext" readonly {{ /if }} />{{ $err.ayisatu_in }}

							</td>
						</tr><tr>
							<th>本状表</th>
							<td>
	<input type="text" name="honjyou_out"  value="{{ $forms.honjyou_out|escape }}"  {{ if $eflg == '1' }} class="text" {{ else }} class="dtext" readonly {{ /if }} />{{ $err.honjyou_out }}

							</td>
						</tr><tr>
							<th>本状裏</th>
							<td>
	<input type="text" name="honjyou_in"  value="{{ $forms.honjyou_in|escape }}"  {{ if $eflg == '1' }} class="text" {{ else }} class="dtext" readonly {{ /if }} />{{ $err.honjyou_in }}

							</td>
						</tr><tr>
							<th>その他１</th>
							<td>
	<input type="text" name="other1"  value="{{ $forms.other1|escape }}"  {{ if $eflg == '1' }} class="text" {{ else }} class="dtext" readonly {{ /if }} />{{ $err.other1 }}

							</td>
						</tr><tr>
	<th>その他2</th>
							<td>
	<input type="text" name="other2"  value="{{ $forms.other2|escape }}"  {{ if $eflg == '1' }} class="text" {{ else }} class="dtext" readonly {{ /if }} />{{ $err.other2 }}

							</td>
						</tr><tr>
	<th>その他3</th>
							<td>
	<input type="text" name="other3" value="{{ $forms.other3|escape }}"  {{ if $eflg == '1' }} class="text" {{ else }} class="dtext" readonly {{ /if }} />{{ $err.other3 }}

							</td>
						</tr><tr>
							<th>その他4</th>
							<td>
	<input type="text" name="other4"  value="{{ $forms.other4|escape }}"  {{ if $eflg == '1' }} class="text" {{ else }} class="dtext" readonly {{ /if }} />{{ $err.other4 }}

							</td>
						</tr><tr>
							<th>その他5</th>
							<td>
	<input type="text" name="other5"  value="{{ $forms.other5|escape }}"  {{ if $eflg == '1' }} class="text" {{ else }} class="dtext" readonly {{ /if }} />{{ $err.other5 }}

							</td>
						</tr>
						

						{{ if $forms.id != '' }}
						<tr>
							<th>店舗</th>
							<td>
				<button type="button" id="shop" class="btn_search_muti" ><span>店舗追加</span></button> {{ $err.mutirow }}
				<table  style="width:85%" id="table_shop">
					<thead>
					</thead>
					<tbody><tr>
							<th>店舗コード</th>	<th>店舗名</th>	<th>件数</th>	<th>操作</th>
						</tr>
{{ foreach from=$forms.mutirow key=k item=v name="member" }}
						<tr>
							<td> {{ $v.shop_cd }} </td>
							<td> {{ $v.shop_name }} </td>
							<td> 
								<input class="text nper" type="text" value="{{ $v.count }}"  id="p_{{ $v.shop_cd }}" name="count[]">{{ $v.errcount }}
								<input type="hidden" name="shop_cd[]" value="{{ $v.shop_cd }}">
								<input type="hidden" name="shop_name[]" value="{{ $v.shop_name }}">
							</td>
							<td align="center">	<button type="button" class="tddel">削除</button></td>
						</tr>
{{ /foreach }}
					</tbody>
				</table>
							</td>
						</tr>
 {{ /if }}

					</tbody>
				</table>
				<p class="button">
{{ if $forms.id != '' }}
					<button type="button" class="btn_return" class="submit"><span>戻る</span></button>
					<button type="button" class="btn_update" class="submit"><span>更新</span></button>
{{ else }}
					<button type="button" class="btn_regist" class="submit"><span>登録</span></button>
{{ /if }}
				</p>
				<input type="hidden" name="id" value="{{ $forms.id }}" />
				<input type="hidden" name="mode" value="" />
			</form>

<div id="dialog" >
</div>
<div id="dialogmuti" >
</div>
{{ /if }}

{{ if $phase == 'complete' }}
			<p class="message">{{ $message }}</p>
			<ul>
				<li>>> <a href="mcost_dm_index.php?hist=2">一覧ページに戻る</a></li>
				<li>>> <a href="mcost_dm_form.php?id={{ $forms.id }}">更新</a></li>
			</ul>
{{ /if }}

		</div></div>
		{{ $footer }}
	</body>
</html>